module("events",package.seeall)
Data=datas.data
Data["events"]={}
hook=function(name, line, wildcards)
  raise(name)
end

bind=function(event,hook)
  if hook then
    hooks=Data["events/"..event] or {}
    hooks[hook]=hook
    Data["events/"..event]=hooks
  end
end
unbind=function(event,hook)
  if hook then
    hooks=Data["events/"..event] or {}
    table.insert(hooks,hook)
    hooks[hook]=nil
    Data["events/"..event]=hooks
  else
    Data["events"]={}
  end
end
raise=function(event,hook)
  t=Data["events/"..event]
  if t then
    table.foreach(t,function(i,v) v() end)
  end
end